﻿using System;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace CalcSharp.MDIUI
{
    public partial class OSDKeyboard : DockContent
    {
        public OSDKeyboard()
        {
            InitializeComponent();
        }

        private void NormalButtonClick(object sender, EventArgs e)
        {
            Button s = (Button)sender;
            Program.ConsoleForm.InsertTextIntoInput(s.Text);
        }

        private void BtnEnter_Click(object sender, EventArgs e)
        {
            Program.ConsoleForm.DoEnter();
        }

        private void BtnSpecial_Click(object sender, EventArgs e)
        {
            Button temp;
            if (BtnSpecial.Text == "Specials")
            {
                BtnSpecial.Text = "Normal";
                foreach (Control ctrl in keypad.Controls)
                {
                    if (ctrl is Button)
                    {
                        temp = (Button)ctrl;
                        switch (temp.Text)
                        {
                            case "ENTER":
                            case "Select":
                            case "Specials":
                            case "Normal":
                            case "space":
                                break;
                            case "2":
                                temp.Text = "@";
                                break;
                            case "3":
                                temp.Text = "#";
                                break;
                            case "4":
                                temp.Text = "$";
                                break;
                            case "6":
                                temp.Text = "^";
                                break;
                            case "7":
                                temp.Text = "&&";
                                break;
                            case "8":
                                temp.Text = "*";
                                break;
                            case "9":
                                temp.Text = "(";
                                break;
                            case "0":
                                temp.Text = ")";
                                break;
                            case "/":
                                temp.Text = "|";
                                break;
                            case "[":
                                temp.Text = "{";
                                break;
                            case "]":
                                temp.Text = "}";
                                break;
                            case ";":
                                temp.Text = ",";
                                break;
                            default:
                                temp.Text = temp.Text.ToUpper();
                                break;
                        }
                    }
                }
            }
            else
            {
                BtnSpecial.Text = "Specials";
                foreach (Control ctrl in keypad.Controls)
                {
                    if (ctrl is Button)
                    {
                        temp = (Button)ctrl;
                        switch (temp.Text)
                        {
                            case "ENTER":
                            case "Select":
                            case "Specials":
                            case "Normal":
                            case "space":
                                break;
                            case "@":
                                temp.Text = "2";
                                break;
                            case "#":
                                temp.Text = "3";
                                break;
                            case "$":
                                temp.Text = "4";
                                break;
                            case "^":
                                temp.Text = "6";
                                break;
                            case "&&":
                                temp.Text = "7";
                                break;
                            case "*":
                                temp.Text = "8";
                                break;
                            case "(":
                                temp.Text = "9";
                                break;
                            case ")":
                                temp.Text = "0";
                                break;
                            case "|":
                                temp.Text = "/";
                                break;
                            case "{":
                                temp.Text = "[";
                                break;
                            case "}":
                                temp.Text = "]";
                                break;
                            case ",":
                                temp.Text = ";";
                                break;
                            default:
                                temp.Text = temp.Text.ToLower();
                                break;
                        }
                    }
                }
            }
        }
    }
}